from utils.viewset import CustomModelViewSet
from .models import Settings
from .serializers import SettingsSerializer
from utils.json_response import SuccessResponse
from .utils import AppSetting


class SettingsViewSet(CustomModelViewSet):
    queryset = Settings.objects.all()
    serializer_class = SettingsSerializer

    def create(self, request, *args, **kwargs):
        params = request.data.get('data', None)
        if params:
            for item in params:
                AppSetting.set(**item)
        return SuccessResponse(data=[])
